package test;



import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
public class Time {
    public static void main(String[] args) {
        String s1 = "2010.09.20";
        String s2 = "2010.09.29";
        Time time = new Time();
        System.out.println("两个时间间隔天数为：" + time.fun(s1, s2));
    }
    public int fun(String s1, String s2) {
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy.MM.dd");
        LocalDate time1 = LocalDate.parse(s1, dateTimeFormatter);
        LocalDate time2 = LocalDate.parse(s2, dateTimeFormatter);
        long between = ChronoUnit.DAYS.between(time1, time2);
        return (int) between;
    }
}
